#!/bin/bash

DATA_DIR=/pdata
DR_FLAG=${DATA_DIR}/DR

cd $DATA_DIR

echo 'data.current' > $DR_FLAG
echo -e "Disaster flag set.\n\nTriggering disaster recovery...this will automatically restart the container."

sleep 5

# Continuously send SIGTERM
PID=$(pidof etcd)
while kill -0 $PID &> /dev/null; do
  kill $PID
  sleep 1
done
